package com.edusys.web.clazz;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edusys.dao.impl.ClazzDaoImpl;
import com.edusys.entity.Clazz;
import com.edusys.service.impl.ClazzServiceImpl;
import com.edusys.web.CommonServlet;
import com.google.gson.Gson;

public class ClazzAllServlet extends CommonServlet {
	private static final long serialVersionUID = 1L;
       
    public ClazzAllServlet() {}
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		super.setChar(request, response);
		List<Clazz> clazz=new ClazzServiceImpl(new ClazzDaoImpl()).findAll(new Clazz());
		String str=new Gson().toJson(clazz);
		PrintWriter out=response.getWriter();
		out.write(str);
		out.flush();
		out.close();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
